#include <stdlib.h>
#include <stdio.h>
#include "dsstring.h" // 请不要删除，否则检查不通过

bool blstr_substr(BLString src, int pos, int len, BLString *sub) {
    if(pos < 0 || len < 1 || pos >= src.len) return 0;
    if(src.len - pos < len) len = src.len - pos;
    Block *blk = src.head; 
    while(pos >= BLOCK_SIZE) blk = blk -> next, pos -= BLOCK_SIZE;
    sub -> len = len;
    Block *dst = sub -> head = malloc(sizeof(Block)); 
    int ptr = 0;
    while(len) {
        dst->ch[ptr++] = blk -> ch[pos++]; --len;
        if(pos == BLOCK_SIZE) blk = blk -> next, pos = 0;
        if(ptr == BLOCK_SIZE && len) {
            dst = dst -> next = malloc(sizeof(Block));
            ptr = 0;
        }
    }
    for(;ptr<BLOCK_SIZE;ptr++) dst -> ch[ptr] = BLS_BLANK;
    sub -> tail = dst;
    return 1;
}

int main(int argc, char const *argv[])
{
    char str[12345]; int pos, len;
    scanf("%s%d%d", str, &pos, &len);
    BLString res; blstr_init(&res);
    bool ret = blstr_substr(blk_new(str), pos, len, &res);
    printf("%d\n", ret);
    blk_print(res);
    return 0;
}
